<template>
  <cfg-table
    :ref="ref"
    :config="config"
    :loading="loading"
    :data="data"
    :columns="columns"
    :additionalAction="additionalAction"
    :pageSizeOpts="pageSizeOpts"
    :pageNavigation="pageNavigation"
    :queryFormItem="queryFormItem"
    :collapseFormItem="collapseFormItem"
    :btnShowFun="btnShowFun"
    :rowbgc="rowbgc"
    :tableStyle="{ overflow: 'hidden !important' }"
    @loadPage="loadPage"
    @handleEdit="handleEdit"
    @handleDelete="handleDelete"
    @handleDetail="handleDetail"
    @handleClick="handleClick"
    @handleDbClick="handleDbClick"
    @handleCreate="handleCreate"
    @handleDeleteMultiple="handleDeleteMultiple"
    @handleSearch="handleSearch"
    @handleReset="handleReset"
    @handleSelect="handleSelect"
    @handleChangePage="handleChangePage"
  ></cfg-table>
</template>

<script>
const ref = "feedTable";
export default {
  name: ref,
  components: {},
  inject: ["anc"],
  data() {
    return {
      ref,
      loading: false,
      pageNavigation: {
        total: 0,
        pageSize: 10,
        pageNumber: 1,
      },
    };
  },
  props: {
    data: {
      default: () => {
        return [];
      },
    },
  },
  watch: {},
  computed: {
    config() {
      return {
        search: true,
        addButton: false,
        batchDeleteButton: false,
        downloadIcon: false,
        uploadIcon: false,
        uploadUrl: "/",
        tableSizeIcon: false,
        fullscreenIcon: false,
        refreshIcon: true,
        columnSettingIcon: true,
        action: false, // 操作
        checkColumnDisabled: false,
        additionalAction: false, // 新增自定义
      };
    },
    columns() {
      return [
        {
          key: "batchNo",
          title: "批次号",
          minWidth: 200,
          align: "center",
          show: true,
        },
        {
          key: "tankNo",
          title: "桶号",
          minWidth: 200,
          align: "center",
          show: true,
        },
        {
          key: "productId",
          title: "规格ID",
          minWidth: 200,
          align: "center",
          show: true,
          render: (h, params) => {
            return h(
              "div",
              {},
              this._$getOptionValue(
                this.anc.productOptions,
                params.row.productId
              )
            );
          },
        },
        {
          key: "status",
          title: "状态",
          minWidth: 200,
          align: "center",
          show: true,
        },
        {
          key: "totalCapacity",
          title: "重量(KG)",
          minWidth: 100,
          align: "center",
          show: true,
        },
        {
          key: "usedCapacity",
          title: "已用重量(KG)",
          minWidth: 100,
          align: "center",
          show: true,
        },
        {
          key: "restCapacity",
          title: "剩余重量(KG)",
          minWidth: 100,
          align: "center",
          show: true,
        },
        {
          key: "qualityResult",
          title: "质检结果",
          minWidth: 200,
          align: "center",
          show: true,
        },
        {
          key: "fsssGrind",
          title: "研磨fsss",
          minWidth: 200,
          align: "center",
          show: true,
        },
        {
          key: "fsssOriginal",
          title: "原态fsss",
          minWidth: 200,
          align: "center",
          show: true,
        },
        {
          key: "ctValue",
          title: "ct值",
          minWidth: 200,
          align: "center",
          show: true,
        },
        {
          key: "storehouseId",
          title: "仓库Id",
          minWidth: 200,
          align: "center",
          show: true,
        },
        {
          key: "locationId",
          title: "库位Id",
          minWidth: 200,
          align: "center",
          show: true,
        },
      ];
    },

    additionalAction() {
      return {
        key: "additionalAction",
        title: "附加操作",
        slot: "additionalAction",
        width: 200,
        fixed: "right",
        align: "center",
        show: true,
        buttons: [
          {
            title: "执行",
            event: (row, index) => console.log(row),
          },
        ],
      };
    },
    pageSizeOpts() {
      return [10, 30, 50, 100];
    },
    // pageNavigation() {
    //   return { total: 0, pageSize: 10, pageNumber: 1 };
    // },
    queryFormItem() {},
    collapseFormItem() {
      return [{ title: "批次号", key: "batchNo", config: { type: "text" } }];
    },
    btnShowFun() {
      return function () {
        return true;
      };
    },
    rowbgc() {
      return "red";
    },
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.$set(this.anc.vms, this.ref, this);
    });
  },
  methods: {
    loadPage(pageNavigation, filter) {
      this.anc.feedLoadPage(this.pageNavigation, filter);
    },
    handleDelete(row, index) {},
    handleEdit(row, index) {},
    handleSelect(selection) {
      this.anc.feedTableSelect(selection);
    },
    handleDetail(row, index) {},
    handleCreate() {},
    handleClick(row, index) {},
    handleDbClick(row, index) {},

    handleDeleteMultiple(selection) {},
    handleReset() {
      this.pageNavigation.pageNumber = 1;
      this.anc.feedLoadPage(this.pageNavigation, {}, "", "", false);
    },
    handleSearch(filter) {
      this.pageNavigation.pageNumber = 1;
      this.anc.feedLoadPage(this.pageNavigation, filter, "", "", false);
    },
    handleChangePage() {},
  },
};
</script>
<style scoped></style>
